package com.gel.codegeneration.core.parser;

import com.gel.codegeneration.ai.model.enums.CodeGenTypeEnum;
import com.gel.codegeneration.common.enums.ErrorCode;
import com.gel.codegeneration.convention.exception.BusinessException;

import static com.gel.codegeneration.ai.model.enums.CodeGenTypeEnum.HTML;
import static com.gel.codegeneration.ai.model.enums.CodeGenTypeEnum.MULTI_FILE;

/**
 * @BelongsProject: code-generation-platform
 * @BelongsPackage: com.gel.codegeneration.core.parser
 * @Author: gel
 * @CreateTime: 2025-08-22  15:45
 * @Description: TODO 代码解析执行器
 * @Version: 1.0
 */
public class CodeParserExecutor {
    private static   HtmlCodeParser htmlCodeParser=new HtmlCodeParser();
    private static  MultiFileParser multiFileParser=new MultiFileParser();

    /**
     * @description: 执行代码解析(Html/MultiFile)
     * @param: [codeContent, codeGenType]
     * @return: java.lang.Object
     * @author: gel
     * @date: 2025/8/22 15:47
     */
    public static Object executeParser(String codeContent, CodeGenTypeEnum codeGenType){
        return switch (codeGenType){
            case HTML->
                    htmlCodeParser.parseCode(codeContent);
            case MULTI_FILE->
                    multiFileParser.parseCode(codeContent);
            default -> {String errorMsg = "不支持的代码生成类型：" + codeGenType.getValue();
            throw new BusinessException(ErrorCode.SYSTEM_ERROR,"不支持的代码生成类型："+codeGenType);}
        };

    }
}
